/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * {{get_generation_time()}}
 * {{get_project_name()}}
 * {{get_vcos_version()}}
 */

/* Including File */
#include "pdur.h"
#include "Os.h"
#if defined (VCOS_OS_CONFIG_SPINLOCK) && (VCOS_OS_CONFIG_SPINLOCK == 1)
#include "Spinlock_Cfg.h"
#endif
#include "pdur_evcfifo.h"
#include "Compiler.h"
#ifndef PDUR_EVCFIFO_EMPTY_SPINLOCK_ID
#define PDUR_EVCFIFO_EMPTY_SPINLOCK_ID
#endif
#ifndef PDUR_IFEVCFIFO_EMPTY_SPINLOCK_ID
#define PDUR_IFEVCFIFO_EMPTY_SPINLOCK_ID
#endif
#if (PDUR_MULTICORE_SUPPORT == STD_ON)
{%- set pdur_evcfifo_cfg = get_pdur_evcfifo_cfg() %}
{%- for evcFifo in pdur_evcfifo_cfg %}
{%- if evcFifo['PduREvCFifoLength'] != 0 %}
#define PDUR_START_SEC_MULTI_APP_BSS
#include "pdur_memmap.h"
static VAR(pdur_evc_data_type, PDUR_MULTI_APP_BSS) pdur_evc_fifo_data_core{{evcFifo['PduREventQueueCore']}}[{{evcFifo['PduREvCFifoLength']}} + 1];
static VAR(pdur_evc_fifo_type, PDUR_MULTI_APP_BSS) pdur_evc_fifo_core{{evcFifo['PduREventQueueCore']}};
#define PDUR_STOP_SEC_MULTI_APP_BSS
#include "pdur_memmap.h"

#define PDUR_START_SEC_CONST
#include "pdur_memmap.h"
static CONST(pdur_evc_fifo_desc_type, PDUR_CONST) pdur_evc_fifo_desc_core{{evcFifo['PduREventQueueCore']}} = {
    /* .Fifo = */           &pdur_evc_fifo_core{{evcFifo['PduREventQueueCore']}},
#if defined (VCOS_OS_CONFIG_SPINLOCK) && (VCOS_OS_CONFIG_SPINLOCK == 1)
    /* .SpinlockID = */     (SpinlockIdType)PDUR_EVCFIFO_{{evcFifo['SpinLockName']}}_SPINLOCK_ID,
#endif
    /* .Data = */           pdur_evc_fifo_data_core{{evcFifo['PduREventQueueCore']}},
    /* .Size = */           ({{evcFifo['PduREvCFifoLength']}} + 1),
};
#define PDUR_STOP_SEC_CONST
#include "pdur_memmap.h"
{%- endif %}
{%- endfor %}

#define PDUR_START_SEC_CONST
#include "pdur_memmap.h"
static CONSTP2CONST(pdur_evc_fifo_desc_type, AUTOMATIC, PDUR_CONST) pdur_evc_fifo_desc_ref_table[PDUR_EVC_FIFO_CORE_MAX_NUM] = {
{%- for evcFifo in pdur_evcfifo_cfg %}
    {%- if evcFifo['PduREvCFifoLength'] > 0 %}
    &pdur_evc_fifo_desc_core{{evcFifo['PduREventQueueCore']}},
    {%- else %}
    NULL,
    {%- endif %}
{%- endfor %}
};
#define PDUR_STOP_SEC_CONST
#include "pdur_memmap.h"
{{''}}


{%- set pdur_if_evcfifo_cfg = get_pdur_if_evcfifo_cfg() %}
{%- if pdur_if_evcfifo_cfg | length != 0%}
{%- for evcIfFifo in pdur_if_evcfifo_cfg %}
{%- if evcIfFifo['PduREvCFifoLength'] > 0 %}
#define PDUR_START_SEC_MULTI_APP_BSS
#include "pdur_memmap.h"
static VAR(pdur_evc_data_type, PDUR_MULTI_APP_BSS) pdur_if_evc_fifo_data_core{{evcIfFifo['PduREventQueueCore']}}[{{evcIfFifo['PduREvCFifoLength']}} + 1];
static VAR(pdur_evc_fifo_type, PDUR_MULTI_APP_BSS) pdur_if_evc_fifo_core{{evcIfFifo['PduREventQueueCore']}};
#define PDUR_STOP_SEC_MULTI_APP_BSS
#include "pdur_memmap.h"

#define PDUR_START_SEC_CONST
#include "pdur_memmap.h"
static CONST(pdur_evc_fifo_desc_type, PDUR_CONST) pdur_if_evc_fifo_desc_core{{evcIfFifo['PduREventQueueCore']}} = {
    /* .Fifo = */           &pdur_if_evc_fifo_core{{evcIfFifo['PduREventQueueCore']}},
#if defined (VCOS_OS_CONFIG_SPINLOCK) && (VCOS_OS_CONFIG_SPINLOCK == 1)
    /* .SpinlockID = */     (SpinlockIdType)PDUR_IFEVCFIFO_{{evcIfFifo['SpinLockName']}}_SPINLOCK_ID,
#endif
    /* .Data = */           pdur_if_evc_fifo_data_core{{evcIfFifo['PduREventQueueCore']}},
    /* .Size = */           ({{evcIfFifo['PduREvCFifoLength']}} + 1),
};
#define PDUR_STOP_SEC_CONST
#include "pdur_memmap.h"
{%- endif %}
{%- endfor %}
{%- endif %}

#define PDUR_START_SEC_CONST
#include "pdur_memmap.h"
static CONSTP2CONST(pdur_evc_fifo_desc_type, AUTOMATIC, PDUR_CONST) pdur_if_evc_fifo_desc_ref_table[PDUR_IF_EVC_FIFO_CORE_MAX_NUM] = {
{%- for evcIfFifo in pdur_if_evcfifo_cfg %}
    {%- if evcIfFifo['PduREvCFifoLength'] > 0 %}
    &pdur_if_evc_fifo_desc_core{{evcIfFifo['PduREventQueueCore']}},
    {%- else %}
    NULL,
    {%- endif %}
{%- endfor %}
};
#define PDUR_STOP_SEC_CONST
#include "pdur_memmap.h"

#define PDUR_START_SEC_CODE
#include "pdur_memmap.h"
FUNC(const pdur_evc_fifo_desc_type * const *, PDUR_CODE) pdur_get_evc_fifo_desc_ref_table(void)
{
    return &pdur_evc_fifo_desc_ref_table[0];
}

FUNC(const pdur_evc_fifo_desc_type * const *, PDUR_CODE) pdur_get_if_evc_fifo_desc_ref_table(void)
{
    return &pdur_if_evc_fifo_desc_ref_table[0];
}
#define PDUR_STOP_SEC_CODE
#include "pdur_memmap.h"
#endif /* PDUR_MULTICORE_SUPPORT */
{{ "" }}